package personal.zq.practice.common.utils;

import java.util.Map;
import com.alibaba.ttl.TransmittableThreadLocal;
/**
 * @author zhangqing
 * @version 1.0
 * @date 2022/9/21
 */
public class ThreadContextUtil extends AbstractThreadContext{

    private static ThreadLocal<Map<String,Object>> threadContext = new TransmittableThreadLocal<>();
    private volatile static ThreadContextUtil app = null;

    private ThreadContextUtil(){}

    public static synchronized ThreadContextUtil getInstance() {
        if (app == null) {
            synchronized (ThreadContextUtil.class) {
                if (app == null) {
                    app = new ThreadContextUtil();
                }
            }
        }
        return app;
    }

    @Override
    protected ThreadLocal<Map<String, Object>> getThreadContext() {
        return threadContext;
    }

}